#MODIFY HERE
#corpus=/data/corpus/ek-all
corpus_train=/home/swlee4skmt/corpus/bilingual/EC/train/
corpus_nist=/home/swlee4skmt/corpus/bilingual/EC/nist08-ce/
scripts=/home/swlee4skmt/svn_co/smt/copycat/exp/scripts
misc=/home/swlee4skmt/svn_co/smt/copycat/misc


########################################################
if [ $# == 3 ]; then
	echo -n ""
else
	echo "usage: ec-data-prepare.sh  [ec|cr|rf]  [st|int|uni]  number(k)"
	exit
fi




type=$1
symm=$2
label=$3

eval=`wc -l ${corpus_nist}ch.pos.utf8 | awk '{ print $1 }'`
dev=1000
let train=label*1000
let all=eval+dev+train
let eval_dev=eval+dev
let eval_train=eval+train


########################################################
echo "Evaluation: " $eval
echo "Development:" $dev
echo "Training:   " $train


#### start automatic generation
dir=_${type}-${symm}-${label}k
echo Creating $dir
rm -rf $dir; mkdir -p $dir;
cd $dir

##### running file
ln -s ${scripts}/run-all.sh .
ln -s ${scripts}/run-smt.sh .

##### INFO
echo Making info
mkdir info
cd info
echo ${eval} > num-eval.var
echo ${dev} > num-dev.var
echo ${train} > num-train.var
echo ${type} > rule_type.var
echo ${symm} > symm.var
cd ..


##### Init
echo Making Init 
mkdir i0; cd i0;
ln -s ${scripts}/copycat.sh .
ln -s ${scripts}/copycat-train.sh .
ln -s ${scripts}/make-next.sh .
echo 0 > now-itr.var



### corpus
echo Making corpus 
mkdir corpus; cd corpus;

#sp
ln -s ${corpus_nist}ch.pos.utf8  src-eval.SP
ln -s ${corpus_train}ch.dev.SP   src-dev.SP
#ln -s ${corpus_train}ch.train.SP src-train.SP
head -${train} ${corpus_train}ch.train.SP > src-train.SP
cat src-eval.SP src-dev.SP src-train.SP > src-all.SP
ln -s ${corpus_train}en.dev.SP    tgt-dev.SP
ln -s ${corpus_nist}en-1.pos.utf8 tgt-eval.SP
#ln -s ${corpus_train}en.train.SP  tgt-train.SP
head -${train} ${corpus_train}en.train.SP > tgt-train.SP
cat tgt-eval.SP tgt-dev.SP tgt-train.SP > tgt-all.SP

#parse
ln -s ${corpus_nist}ch.parsed.utf8   src-eval.parse
ln -s ${corpus_train}ch.dev.parse   src-dev.parse
#ln -s ${corpus_train}ch.train.SP src-train.parse
head -${train} ${corpus_train}ch.train.parse > src-train.parse
cat src-eval.parse src-dev.parse src-train.parse > src-all.parse

cd ..


### WA
echo Making wa
mkdir wa; cd wa;
ln -s ../corpus/src-all.SP src.SP
ln -s ../corpus/tgt-all.SP tgt.SP
ln -s ${scripts}/run-giza.sh .
ln -s ${scripts}/eval.sh .
ln -s ${misc}/giza_st.cfg .
ln -s ${misc}/giza_ts.cfg .
cd ..;

# SMT data
echo Making smt
mkdir smt; cd smt;
cat ${scripts}/Makefile | sed s/VARIABLE/_${type}-${symm}-${label}/ > Makefile
ln -s ../corpus/src-eval.SP ./src-eval.utf8
ln -s ../corpus/src-dev.SP ./src-dev.utf8
ln -s ../corpus/src-train.SP ./src-train.utf8
ln -s ../corpus/tgt-eval.SP ./tgt-eval.utf8
ln -s ../corpus/tgt-dev.SP ./tgt-dev.utf8
ln -s ../corpus/tgt-train.SP ./tgt-train.utf8
cd ..;

cd ..;
echo Done

